/**
 * Copyright 2013-2015 JueYue (qrb.jueyue@gmail.com)
 * <p>
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * <p>
 * http://www.apache.org/licenses/LICENSE-2.0
 * <p>
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.xncoding.easypoi.service;

import cn.afterturn.easypoi.excel.entity.result.ExcelVerifyHandlerResult;
import cn.afterturn.easypoi.handler.inter.IExcelVerifyHandler;
import com.xncoding.easypoi.model.AlarmObj;

import java.math.BigDecimal;
import java.util.Map;

public class ExcelVerifyHandlerImpl implements IExcelVerifyHandler<Map<String, Object>> {

    @Override
    public ExcelVerifyHandlerResult verifyHandler(Map<String, Object> obj) {
        StringBuilder builder = new StringBuilder();
      String tranAmt = (String) obj.get("tranAmt");
        if (!isBigDecimal(tranAmt)) {
            builder.append("not bigddecimal");
            return new ExcelVerifyHandlerResult(false, builder.toString());
        }
        return new ExcelVerifyHandlerResult(true, builder.toString());
    }

    /**
     *
     * 说明：判断是否为BigDecimal
     * @param str
     * @return
     */
    public static boolean isBigDecimal(String integer) {
        try {
            BigDecimal bd = new BigDecimal(integer);
            return true;
        } catch (NumberFormatException e) {
            return false;
        }
    }

}
